package redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.List;

public class RedisDemoList {
    public static void test1(Jedis jedis){
        System.out.println("blpop");
        jedis.flushAll();



        //返回结果是一个“二元组”，一个是从哪个 key 对应的 list中删除的，一个是删除的元素是什么.
        List<String> value = jedis.blpop(20,"key");
        System.out.println("value[0]:" + value.get(0));
        System.out.println("value[1]:" + value.get(1));
    }

    public static void test2(Jedis jedis) {
        System.out.println("llen");
        long ret = jedis.llen("key");
        System.out.println(ret);
        //jedis.flushAll();

        jedis.rpush("key","111","222","333");

         ret = jedis.llen("key");
        System.out.println(ret);
    }


    public static void main(String[] args) {
        JedisPool jedisPool = new JedisPool("tcp://127.0.0.1:8888");
        try (Jedis jedis = jedisPool.getResource()) {
            //test1(jedis);
            test2(jedis);

        }
    }
}
